# haproxy instance definition
{% for proxy in haproxy_instances %}
upstream {{ proxy.cluster }}-{{ proxy.seq }} {
    server {{ proxy.ip }}:{{ proxy.port }} max_fails=0;
}
{% endfor %}


# nginx proxy for haproxy admin
server {
    listen       80;
    server_name  {{ haproxy_hostname }};

{% for proxy in haproxy_instances %}
    location ^~/{{ proxy.cluster }}-{{ proxy.seq }}/ {
        proxy_pass http://{{ proxy.cluster }}-{{ proxy.seq }};
        proxy_connect_timeout 2;
    }
{% endfor %}

    location / {
        root        {{ repo_home }}/;
        index       haproxy.html;
    }
}